import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:guochaoapp/common/widges/appbar.dart';
import 'package:guochaoapp/controller/home/selectregion_controller.dart';

class GCSelectRegion extends StatelessWidget {
  final c = Get.put(GCSelectRegionController());

  @override
  Widget build(BuildContext context) {
    c.requestUsersDealers();

    return Scaffold(
      backgroundColor: Theme.of(Get.context).scaffoldBackgroundColor,
      appBar: GCAppBar(titleText: "选择所在地区"),
      body: _initSubViews((index) => c.didSelectedRegion(index)),
    );
  }

  _initSubViews(Function itemTap) {
    return Obx(() => ListView.builder(
      itemBuilder: (context, index) {
        return GestureDetector(
          onTap: () => {
            itemTap(index)
          },
          child: Container(
            height: 43,
            child: Column(
              children: [
                Container(height: 1, color: Colors.transparent),
                Expanded(
                  child: Container(
                    color: Colors.white,
                    child: Row(children: [
                      SizedBox(width: 16),
                      Text(c.dealersList[index].location, style: TextStyle(fontSize: 16, color: Color(0xFF666666))),
                      Expanded(child: SizedBox()),
                      Icon(Icons.keyboard_arrow_right, color: Color(0xFF333333)),
                      SizedBox(width: 16),
                    ],
                    ),
                  ),
                ),
              ],
            ),
          ),
        );
      },
      itemCount: c.dealersList.length,
    )
    );
  }

}
